<template>
    <div class="e-form">
        <BillTop :title="$route.meta.title" @cancel="handleClose"></BillTop>
        <div class="tabs warningTabs"></div>
        <div class="tabs" v-if="Object.keys(formData).length != 0">
            <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
                <el-tab-pane
                    label="基本信息"
                    name="baseInfo"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane label="资质信息" name="quaInfo" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane
                    label="企业主要业绩"
                    name="enterprise"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="企业主要管理人"
                    name="manager"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="报名合同段"
                    name="registrSection"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane label="附件信息" name="attach" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane
                    label="审核历史"
                    name="auditHistory"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <div>
                    <div id="baseInfoCon" class="con">
                        <div class="tabs-title" id="baseInfo">基本信息</div>
                        <div style="width: 100%" class="form">
                            <el-form ref="form" :model="form" label-width="170px">
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="招标编号：">
                                            <span>{{ tenderFormData.billNo }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="拟招标项目名称：">
                                            <span>{{ tenderFormData.tenderName }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="招标类型：">
                                            <span>{{
                                                tenderFormData.tenderClass | tenderClass(this)
                                            }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="报名日期：">
                                            <span>{{ formData.baseInfo.enrollTime }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="统一社会信用代码：">
                                            <span>{{ formData.baseInfo.unitCode }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="单位名称：">
                                            <span>{{ formData.baseInfo.unitName }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="法人代表：">
                                            <span>{{ formData.baseInfo.legalRepresentative }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="注册资本(万元)：">
                                            <span>{{ formData.baseInfo.registerCaptial }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="纳税类别：">
                                            <span>{{ formData.baseInfo.taxpayerType }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="注册地址：">
                                            <span>{{ formData.baseInfo.addressCode }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="联系电话：">
                                            <span>{{ formData.baseInfo.telephone }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="固定电话：">
                                            <span>{{ formData.baseInfo.fixedTelephone }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="传真：">
                                            <span>{{ formData.baseInfo.fax }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="邮箱：">
                                            <span>{{ formData.baseInfo.email }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="代理人：">
                                            <span>{{ formData.baseInfo.proxyUser }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="邮编：">
                                            <span>{{ formData.baseInfo.test }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="外包方类型：">
                                            <span>{{ formData.baseInfo.outsourceType }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="管理单位：">
                                            <span>{{ formData.baseInfo.test }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="申请机构：">
                                            <span>{{ formData.baseInfo.a }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="状态：">
                                            <span>{{ formData.baseInfo.test }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="境外单位：">
                                            <span>{{ formData.baseInfo.isAbroad }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="固定工作地址：">
                                            <span>{{ formData.baseInfo.fixAddressCode }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="企业基本情况：">
                                            <span>{{ formData.baseInfo.enterpriseBase }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="企业注册建造师数量：">
                                            <span>{{
                                                formData.baseInfo.certifiedConstructorNum
                                            }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="中级及以上职称人员数量：">
                                            <span>{{ formData.baseInfo.middlePosition }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="持有岗位证书的施工现场管理人员数量：">
                                            <span>{{ formData.baseInfo.certificateScene }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item
                                            label="经考核或培训合格的中级以上技术工人数量："
                                        >
                                            <span>{{ formData.baseInfo.middleTechnology }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="持有安全C证人员数量：">
                                            <span>{{ formData.baseInfo.safetyNum }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="正常缴纳报销人数：">
                                            <span>{{ formData.baseInfo.test }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="作废人员：">
                                            <span>{{ formData.baseInfo.nullifyCreator }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="作废时间：">
                                            <span>{{ formData.baseInfo.nullifyCreated }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="作废原因：">
                                            <span>{{ formData.baseInfo.nullifyReason }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="作废说明：">
                                            <span>{{ formData.baseInfo.nullifyDesciption }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </div>
                    </div>

                    <div id="quaInfoCon" class="con">
                        <div class="tabs-title" id="quaInfo">资质信息</div>
                        <div>
                            <el-button type="success" @click="quaInfoAdd">添加行</el-button>
                            <el-button @click="tableDel('quaInfo')">删除行</el-button>
                        </div>
                        <el-table
                            :data="formData.applyQualifications"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('quaInfo', $event)"
                            :max-height="$store.state.tableHeight"
            ref="table"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column show-overflow-tooltip width="100" label="操作">
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="certificateType"
                                label="证书类型"
                                class-name="blue-column"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="
                                                formData.applyQualifications[$index].certificateType
                                            "
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="certificateNo"
                                label="证书及编号"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="
                                                formData.applyQualifications[$index].certificateNo
                                            "
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="certificateGrade"
                                label="主营范围/证书等级"
                                width="150"
                            >
                                <template slot-scope="{ row }">
                                    <div v-if="row.frontState === 1">
                                        <span>
                                            <el-input
                                                v-if="
                                                    row.certificateType === '营业执照' ||
                                                    row.certificateType === '资质证书'
                                                "
                                                readonly
                                                v-model="row.certificateGrade"
                                                placeholder="请选择"
                                            >
                                                <i
                                                    slot="suffix"
                                                    class="el-icon-document-copy"
                                                    @click="onSelect(row)"
                                                    style="cursor: pointer"
                                                ></i>
                                            </el-input>
                                        </span>
                                    </div>
                                    <span v-else>{{ row.certificateGrade }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="validateStart"
                                label="有效期开始日期"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="
                                                formData.applyQualifications[$index].validateStart
                                            "
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="validateEnd"
                                label="有效期结束日期"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="
                                                formData.applyQualifications[$index].validateEnd
                                            "
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="fileName"
                                label="文件名"
                                width="150"
                            >
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="fileSize"
                                label="大小"
                                width="150"
                            >
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="upTime"
                                label="上传时间"
                                width="150"
                            >
                            </el-table-column>
                            <el-table-column show-overflow-tooltip label="操作" width="150">
                                <template slot-scope="{ row }">
                                    <el-upload
                                        class="upload-demo"
                                        :action="ip"
                                        :on-preview="handlePreview"
                                        :on-remove="handleRemove"
                                        :before-remove="beforeRemove"
                                        multiple
                                        :limit="3"
                                        :on-exceed="handleExceed"
                                        :file-list="fileList"
                                        :data="{
                                            bucketName: 'tender',
                                            relationId: row.recordId
                                        }"
                                        name="files"
                                        :on-success="onSuccess"
                                        :on-error="onError"
                                    >
                                        <el-button size="small" type="success">上传</el-button>
                                    </el-upload>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="enterpriseCon" class="con">
                        <div class="tabs-title" id="enterprise">企业主要业绩</div>
                        <div>
                            <el-button type="success" @click="enterpriseAdd">添加行</el-button>
                            <el-button @click="tableDel('enterprise')">删除行</el-button>
                        </div>
                        <el-table
                            :data="formData.history"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('enterprise', $event)"
                            :max-height="$store.state.tableHeight"
            ref="table"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column show-overflow-tooltip width="100" label="操作">
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="contractName"
                                label="合同名称"
                                class-name="blue-column"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].contractName"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="projectName"
                                label="项目名称"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].projectName"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="contractAmount"
                                label="合同金额（元）"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].contractAmount"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="workContent"
                                label="所承担工作内容"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].workContent"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="startTime"
                                label="开工时间"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <el-date-picker
                                            v-model="formData.history[$index].startTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                        >
                                        </el-date-picker>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="endTime"
                                label="竣工时间"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <el-date-picker
                                            v-model="formData.history[$index].endTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                        >
                                        </el-date-picker>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="personInCharge"
                                label="项目负责人"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].personInCharge"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="witness"
                                label="业绩证明人"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].witness"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="witnessPhone"
                                label="证明人电话"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].witnessPhone"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="safetyEvaluation"
                                label="质量安全信誉评价意见"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.history[$index].safetyEvaluation"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="proveFile"
                                label="证明附件"
                                width="150"
                            >
                                <template slot-scope="{ row }">
                                    <el-upload
                                        class="upload-demo"
                                        :action="ip"
                                        :on-preview="handlePreview"
                                        :on-remove="handleRemove"
                                        :before-remove="beforeRemove"
                                        multiple
                                        :limit="3"
                                        :on-exceed="handleExceed"
                                        :file-list="fileList"
                                        :data="{
                                            bucketName: 'tender',
                                            relationId: row.recordId
                                        }"
                                        name="files"
                                        :on-success="onSuccess"
                                        :on-error="onError"
                                    >
                                        <el-button size="small" type="success">上传</el-button>
                                    </el-upload>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="managerCon" class="con">
                        <div class="tabs-title" id="manager">企业主要管理人</div>
                        <div>
                            <el-button type="success" @click="managerAdd">添加行</el-button>
                            <el-button @click="tableDel('manager')">删除行</el-button>
                        </div>
                        <el-table
                            :data="formData.applyPersonnels"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('manager', $event)"
                            :max-height="$store.state.tableHeight"
            ref="table"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column show-overflow-tooltip width="100" label="操作">
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="type"
                                label="类型"
                                class-name="blue-column"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.applyPersonnels[$index].type"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="name"
                                label="姓名"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.applyPersonnels[$index].name"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="idCardNo"
                                label="身份证号码"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.applyPersonnels[$index].idCardNo"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="certNo"
                                label="证书及编号"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.applyPersonnels[$index].certNo"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="phone"
                                label="联系电话"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <textarea
                                            class="el-textarea__inner"
                                            rows="1"
                                            v-model="formData.applyPersonnels[$index].phone"
                                            placeholder="请输入内容"
                                            style="resize: none"
                                        ></textarea>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="startTime"
                                label="身份证有效开始时间"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <el-date-picker
                                            v-model="formData.applyPersonnels[$index].startTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                        >
                                        </el-date-picker>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="endTime"
                                label="身份证有效结束时间"
                                label-class-name="required"
                                width="150"
                            >
                                <template slot-scope="{ row, $index }">
                                    <div>
                                        <el-date-picker
                                            v-model="formData.applyPersonnels[$index].endTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                        >
                                        </el-date-picker>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="applyOrgName"
                                label="身份证附件"
                                width="150"
                            >
                                <template slot-scope="{ row }">
                                    <el-upload
                                        class="upload-demo"
                                        :action="ip"
                                        :on-preview="handlePreview"
                                        :on-remove="handleRemove"
                                        :before-remove="beforeRemove"
                                        multiple
                                        :limit="3"
                                        :on-exceed="handleExceed"
                                        :file-list="fileList"
                                        :data="{
                                            bucketName: 'tender',
                                            relationId: row.recordId
                                        }"
                                        name="files"
                                        :on-success="onSuccess"
                                        :on-error="onError"
                                    >
                                        <el-button size="small" type="success">上传</el-button>
                                    </el-upload>
                                </template>
                            </el-table-column>
                            <!-- <el-table-column show-overflow-tooltip label="" width="1">
                              <template slot-scope="scope">
                                  <div>
                                      <i
                                          class="el-icon-edit"
                                          style="cursor: pointer; font-size: 20px"
                                          :class="{
                                              'icon-edit-active-color': MouseEnterId == scope.row.billId
                                          }"
                                          @click="editData(scope.row.billId)"
                                      ></i>
                                  </div>
                              </template>
                          </el-table-column> -->
                        </el-table>
                    </div>

                    <div id="registrSectionCon" class="con">
                        <div class="tabs-title" id="registrSection">报名合同段</div>
                    </div>

                    <div id="attachCon" class="con">
                        <div class="tabs-title" id="attach">附件信息</div>
                        <div>
                            <el-button type="success" @click="attachAdd">添加行</el-button>
                            <el-button @click="tableDel('attach')">删除行</el-button>
                        </div>
                        <el-table
                            :data="attachTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange('attach', $event)"
                            :max-height="$store.state.tableHeight"
            ref="table"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column show-overflow-tooltip width="100" label="操作">
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop=""
                                label="类型"
                                class-name="blue-column"
                            >
                            </el-table-column>
                            <el-table-column show-overflow-tooltip prop="objectName" label="文件名">
                            </el-table-column>
                            <el-table-column show-overflow-tooltip prop="objectSize" label="大小">
                            </el-table-column>
                            <el-table-column
                                show-overflow-tooltip
                                prop="gmtCreate"
                                label="上传时间"
                            >
                            </el-table-column>
                            <!-- <el-table-column show-overflow-tooltip label="" width="1">
                              <template slot-scope="scope">
                                  <div>
                                      <i
                                          class="el-icon-edit"
                                          style="cursor: pointer; font-size: 20px"
                                          :class="{
                                              'icon-edit-active-color': MouseEnterId == scope.row.billId
                                          }"
                                          @click="editData(scope.row.billId)"
                                      ></i>
                                  </div>
                              </template>
                          </el-table-column> -->
                            <el-table-column show-overflow-tooltip label="操作">
                                <el-upload
                                    class="upload-demo"
                                    :action="ip"
                                    :on-preview="handlePreview"
                                    :on-remove="handleRemove"
                                    :before-remove="beforeRemove"
                                    multiple
                                    :limit="3"
                                    :on-exceed="handleExceed"
                                    :file-list="fileList"
                                    :data="{
                                        bucketName: 'tender',
                                        relationId: formData.baseInfo.billId
                                    }"
                                    name="files"
                                    :on-success="onSuccess"
                                    :on-error="onError"
                                >
                                    <el-button size="small" type="success">上传</el-button>
                                </el-upload>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="auditHistoryCon" class="con">
                        <div class="tabs-title" id="auditHistory">审核历史</div>
                    </div>
                </div>
            </el-tabs>
        </div>
        <div class="buttons">
            <!-- <el-button type="primary" class="btn-blue">打印</el-button> -->
            <el-popconfirm title="请问确认删除吗？" @confirm="delData" style="padding: 0 10px">
                <el-button type="primary" slot="reference" class="btn-blue">删除</el-button>
            </el-popconfirm>
            <el-button type="primary" class="btn-blue">发布</el-button>
            <el-button type="primary" class="btn-blue">审核</el-button>
            <el-button type="primary" class="btn-blue">撤回</el-button>
            <el-button type="primary" class="btn-blue" @click="submit">保存</el-button>
            <el-button @click="handleClose">取消</el-button>
        </div>
        <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <span style="display: none">{{ localPopConfirm }}</span>
        <el-dialog
            :title="dialogTitle"
            :visible.sync="dialogVisible"
            width="50%"
            style="padding: 50px"
        >
            <span>
                <el-tree
                    :props="props"
                    :load="loadNode"
                    lazy
                    show-checkbox
                    style="margin-top: 20px"
                    @check-change="treeCheckChange"
                    :key="treeKey"
                >
                </el-tree>
            </span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="diaLogSubmit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
// import ComTreeTable from '@/templates/table/treeTable.vue'
// import ComTreeFile from '@/templates/table/treeFile.vue'
// import ComPagination from '@/components/pagination/pagination.vue'
import enrollRequest from '@/api/tender/enroll.js'
import commonRequest from '@/api/tender/common.js'
import applyRequest from '@/api/tender/apply.js'
import { mapState } from 'vuex'

export default {
    data () {
        return {
            tenderFormData: {},
            tabsName: 'baseInfo',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            tableData: [],
            value: '',
            textarea: '',
            formData: {},
            test: '',
            selectData: [],
            selectTableColumnAttr: [
                {
                    label: '单据编号',
                    prop: 'billNo'
                },
                {
                    label: '拟招标项目名称',
                    prop: 'tenderName'
                },
                {
                    label: '单据日期',
                    prop: 'gmtCreate'
                },
                {
                    label: '单据机构名称',
                    prop: 'orgName'
                }
            ],
            selectTableColumnWidth: {
                leftWidth: '150',
                rightWidth: '100'
            },
            selectDataPagination: {},
            loadComponent: new Set(),
            dialogVisible: false,
            dialogTitle: '',
            props: {
                label: 'kvValue',
                // children: 'zones',
                isLeaf: 'isLeaf'
            },
            treeCheckSet: new Set(),
            row: null, //资质信息 主营范围/资质等级 回调弹窗保存的当前row
            treeKey: 0
        }
    },
    computed: {
        ...mapState({
            options: state => state.biddingApplication.dictionaries
        }),
        tenderId () {
            // return this.formData.baseInfo.a.tenderApplyId
            return this.$route.query.tenderId || this.$route.query.billid //假数据
        },
        billId () {
            return this.$route.query.billId || this.$route.query.billid
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        }
    },
    components: {
        // ComTreeTable,
        // ComTreeFile,
        // ComPagination
    },
    created () {
        this.tenderApplyFindById() // 获取招标详情
        this.getData() // 获取招标报名详情
    },
    mounted () {
        // 保存所有tabName
        const arr = [
            'baseInfo',
            'quaInfo',
            'enterprise',
            'manager',
            'registrSection',
            'attach',
            'auditHistory'
        ]
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight(arr)
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }

            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    const itemTop = document.getElementById(item)?.offsetTop
                    return itemTop
                })
            }
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if (scrollTop + 1 >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item)?.offsetTop
                return itemTop
            })
        })
    },
    beforeDestroy () {
        this.$notify.closeAll()
    },
    methods: {
        diaLogSubmit () {
            this.dialogVisible = false
            this.row.certificateGrade = [...this.treeCheckSet].join(',')
        },
        treeCheckChange (data, isCheck) {
            if (isCheck) {
                this.treeCheckSet.add(data.kvValue)
            } else {
                this.treeCheckSet.delete(data.kvValue)
            }
        },
        async loadNode (node, resolve) {
            console.log('this.dialogTitle', this.dialogTitle)
            if (node.level === 0) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: 0
                })
                return resolve(res)
            }
            if (node.level >= 1) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: node.data.kvId
                })
                return resolve(res)
            }
        },
        onSelect (row) {
            // 需要刷新 主营范围/证书等级 接口
            this.treeKey += 1
            // 弹窗后需要改变，所以保存
            this.row = row
            this.dialogVisible = true
            console.log('row.certificateType', row.certificateType)
            this.dialogTitle =
                row.certificateType === '营业执照' ? '请选择主营范围' : '请选择资质等级'
        },
        diyWindowResize () {
            if (document.createEvent) {
                var event = document.createEvent('HTMLEvents')
                event.initEvent('resize', true, true)
                window.dispatchEvent(event)
            } else if (document.createEventObject) {
                window.fireEvent('onresize')
            }
        },
        ifLoadComponent (component) {
            return this.loadComponent.has(component)
        },
        tenderApplyFindById () {
            applyRequest.tenderApplyFindById(this.tenderId).then(res => {
                this.tenderFormData = res
            })
        },
        onChangeTab (e) {
            console.log('clickTabFlag: ', this.clickTabFlag)
            $.scrollTo(`#${e.name}`, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
            // 按需加载组件
            if (!this.ifLoadComponent(this.tabsName)) {
                this.diyWindowResize()
            }
            this.loadComponent.add(e.name)
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight (arr) {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById(arr[length - 1] + 'Con')) {
                    const lastConHeight = document.getElementById(
                        arr[length - 1] + 'Con'
                    )?.offsetHeight
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        getData () {
            enrollRequest.findById(this.billId).then(res => {
                this.formData = res
            })
        },
        showBidding () {
            if (!this.tenderId) return // 前期需求可切换，现在不需要
            this.$notify.closeAll()
            this.$notify({
                title: '查看招标详情',
                dangerouslyUseHTMLString: true,
                message: `正式环境：客户端打开新页面<br>
                测试环境：手动打开新页面<br>
                <textarea cols="35" rows="10">http://localhost:8080/biddingApplicationShow?tenderId=${this.tenderId}</textarea>
                `,
                duration: 0
            })
            // this.$router.push({
            //     path: './biddingApplicationShow',
            //     query: { tenderId: this.tenderId }
            // })
        },
        submit () {
            // bidNoticeRequest.update(this.formData).then(res => {
            //     // this.dialogVisible = false
            //     this.$router.push({
            //         path: './biddingApplicationEdit',
            //         query: { billid: this.tenderId, seat: 'reg' }
            //     })
            // })
        },
        getNowDate () {
            // 个位数前补0
            const zeroFill = function (num) {
                if (parseInt(num) < 10) {
                    num = '0' + num
                }
                return num
            }
            let nowtime = new Date()
            nowtime =
                zeroFill(nowtime.getFullYear()) +
                '-' +
                zeroFill(nowtime.getMonth() + 1) +
                '-' +
                zeroFill(nowtime.getDate())
            this.$set(this.formData, 'applyTime', nowtime)
        },
        handleClose () {
            this.$router.push({
                path: './otherBiddingApplicationEdit',
                query: { billid: this.tenderId, seat: 'reg' }
            })
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        }
    }
}
</script>

<style lang="scss" scoped>
.form {
    margin-top: 10px;
}

.e-table {
    background: #fff;

    /* .top {
    .left {
      padding: 20px;
      padding-top: 0px;
    }
  } */
}

.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>
